package com.training.admin.dto;

import java.beans.Transient;
import java.util.Date;

import org.apache.commons.lang3.StringUtils;

import com.training.admin.entity.course.Course;

public class CourseRequest {
	
	
	  /**
     * 课程编号
     */
    private String code;
    /**
     * 课程名称
     */
    private String name;
    /**
     * 课时
     */
    private Float hour;
    /**
     * 课程目标
     */
    private String target;

    private String description;
    /**
     * 讲授次数
     */
    private int courseTime;
    
    /**
     * 讲师id
     */
    private Long trainerId;
    
    /**
     * 课程性质
     */
    private String property;
    /**
     *  课程类别（管理类/专业通识类）
     */
    private String type;
    
    
    /**
	 * @return the type
	 */
	public String getType() {
		return type;
	}

	/**
	 * @param type the type to set
	 */
	public void setType(String type) {
		this.type = type;
	}

	/**
     * The default constructor
     */
	public CourseRequest() {
	
	}

	/**
	 * 
	 * @return
	 */
	@Transient
	public boolean validate() {
		boolean result = StringUtils.isNotBlank(this.name) &&
						 (this.hour > 0) &&
						 StringUtils.isNotBlank(this.target) &&
						 StringUtils.isNotBlank(this.description);
		return result;
		
	}
	
	/**
	 * 
	 * @return
	 */
	@Transient
	public Course generateCourse() {
		Course course = new Course();
		course.setCode("s"+new Date().getTime());
		course.setName(this.name);
		course.setHour(this.hour);
		course.setTarget(this.target);
		course.setDescription(this.description);
		course.setProperty("标准课程");
		course.setType(this.type);
		return course;
	}

	/**
	 * @return the code
	 */
	public String getCode() {
		return code;
	}

	/**
	 * @return the name
	 */
	public String getName() {
		return name;
	}

	/**
	 * @return the hour
	 */
	public Float getHour() {
		return hour;
	}

	/**
	 * @return the target
	 */
	public String getTarget() {
		return target;
	}

	/**
	 * @return the description
	 */
	public String getDescription() {
		return description;
	}

	/**
	 * @return the courseTime
	 */
	public int getCourseTime() {
		return courseTime;
	}

	/**
	 * @param code the code to set
	 */
	public void setCode(String code) {
		this.code = code;
	}

	/**
	 * @param name the name to set
	 */
	public void setName(String name) {
		this.name = name;
	}

	/**
	 * @param hour the hour to set
	 */
	public void setHour(Float hour) {
		this.hour = hour;
	}

	/**
	 * @param target the target to set
	 */
	public void setTarget(String target) {
		this.target = target;
	}

	/**
	 * @param description the description to set
	 */
	public void setDescription(String description) {
		this.description = description;
	}

	/**
	 * @param courseTime the courseTime to set
	 */
	public void setCourseTime(int courseTime) {
		this.courseTime = courseTime;
	}

	/**
	 * @return the trainerId
	 */
	public Long getTrainerId() {
		return trainerId;
	}

	/**
	 * @param trainerId the trainerId to set
	 */
	public void setTrainerId(Long trainerId) {
		this.trainerId = trainerId;
	}

	/**
	 * @return the property
	 */
	public String getProperty() {
		return property;
	}

	/**
	 * @param property the property to set
	 */
	public void setProperty(String property) {
		this.property = property;
	}
    
}
